<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="/tailwindcss/tailwindcss.css"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/elementui/css/index.css">
    <script src="/elementui/js/vue.js"></script>
    <script src="/elementui/js/index.js"></script>
    <script src="https://www.layuicdn.com/layui-v2.8.0/layui.js"></script>
    <!-- 引入 Font Awesome 图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
    <script>
        axios.defaults.headers = {
            'withCredentials': true,
            'Content-Type': 'multipart/form-data'
        }
    </script>
</head>
<body>
<div id="app">
    <div class="flex items-center justify-center h-screen bg-gradient-to-r from-blue-500 to-teal-500">
        <div class="bg-white shadow-md rounded p-8 w-full max-w-sm mx-auto">
            <div class="text-center text-4xl">
                <h3>登录帐户</h3>
            </div>
            <el-form class="mt-4" :model="adminUser" ref="adminUser">
                <el-form-item
                        label="帐号"
                        prop="username">
                    <el-input v-model.number="adminUser.username" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item
                        label="密码"
                        prop="password">
                    <el-input v-model.number="adminUser.password" type="password" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="loginAct">登录</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</div>
</body>

<script>
    new Vue({
        el: '#app',
        data: function () {
            return {
                adminUser: {
                    username: "",
                    password: "",
                },
                visible: false
            }

        },
        methods: {
            loginAct() {
                let that = this;
                console.log(this.adminUser);
                axios.post('/admin/login/act', this.adminUser).then(function (res) {
                    res = res.data;
                    if (res.code == 0) {
                        window.location.href = res.data.callback ? res.data.callback : "/admin/dashboard"
                    } else {
                        that.$message.error(res.msg);
                    }
                }).catch(function (err) {
                    that.$message.error(err.msg);
                }).finally(function () {

                });
            }
        },
    })
</script>
</html>